﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Text;
using System.Web.SessionState;


namespace jnlamp.Web.devinfo
{
    /// <summary>
    /// GetJB 的摘要说明
    /// </summary>
    public class GetJB : IHttpHandler, IRequiresSessionState
    {
        jnlamp.BLL.dbstatus bll = new jnlamp.BLL.dbstatus();
        public void ProcessRequest(HttpContext context)
        {

            string ac = "";
            if (null != context.Request.Form["action"])
            {//获取前台传来的值  
                ac = context.Request.Form["action"].ToString().Trim();
            }
            else if (null != context.Request.QueryString["action"])
            {
                ac = context.Request.QueryString["action"].ToString().Trim();
            }

            if (ac == "query")
                Query(context);            
        }
        public void Query(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int uid = Web.Admin.myinfo.getID(context);
            if (uid != 0)
            {
                string jbdata = "", jbarea = "";

                if (null != context.Request.Form["jbdata"])
                {
                    jbdata = context.Request.Form["jbdata"].ToString().Trim();
                }
                if (null != context.Request.Form["jbarea"])
                {//获取前台传来的值  
                    jbarea = context.Request.Form["jbarea"].ToString().Trim();
                }
                string outname=ExWord.ExportToWordExped(jbarea, jbdata);

                context.Response.Write(outname);//返回给前台页面  
                context.Response.End();
              //   context.Response.ContentType = "application/octet-stream";
              //context.Response.AddHeader("content-disposition", "attachment;filename=SName.doc");
              //System.IO.FileInfo lFileInfo = new System.IO.FileInfo(outname);  
              //context.Response.WriteFile(lFileInfo.FullName);
              // context.Response.End();
                
            }
            else
            {
                context.Response.Write("L");//返回给前台页面  
                context.Response.End();
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}